const axios = require('axios')
const checker = require('../utils/checker')
const { info } = require('../utils/output')
const { idParser } = require('../utils/parser')

module.exports = async (idUrl) => {
  info('尝试获取id...')
  const { data } = await axios.get(idUrl)

  // 解析和验证 id
  const id = idParser(data)
  checker(id, '获取成功：' + id.substring(0, 4).padEnd(40, '*') + id.substring(40, 44), '无法获取id')
  return id
}